public class LogCalculator extends Calculator {

    @Override
    public int sum(int a, int b) {
        System.out.printf("程序的入参是a=%s,b=%s%n", a, b);
        long startTime = System.currentTimeMillis();
        // 调用父类的sum方法, 实现代码复用的同时，还实现了新需求，增加了打印日志的功能
        int result = super.sum(a, b);
        long endTime = System.currentTimeMillis();
        System.out.println("程序的计算结果是result=" + result + ", 耗时：" + (endTime - startTime) + "毫秒");
        return result;
    }

}
